﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Castle.ActiveRecord;
using NHibernate.Criterion;
using LIB;
using System.Collections;

public partial class danh_muc_nha : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            if(!IsPostBack)
            {
                int catID = ConvertUtility.ToInt32(Request.QueryString["id"]);
                if (catID > 0)
                {
                    Category_Info catInfo = Category_Info.Find(catID);
                    hidCatID.Value = ConvertUtility.ToString(catID);
                    Category_Info catParentInfo=catInfo.catParentID;
                    if (catParentInfo.id == 41)
                        litPos.Text = "<a href='/cac-muc-gia.aspx'>Các mức giá</a> <img src='/images/bul4.png'/> " + catInfo.catName;
                    else if(catParentInfo.id==44)
                        litPos.Text = "<a href='/loai-bat-dong-san.aspx'>Loại bất động sản</a> <img src='/images/bul4.png'/> " + catInfo.catName;
                    else
                        litPos.Text = "<a href='/du-an-khu-do-thi.aspx'>Dự án, khu đô thị</a> <img src='/images/bul4.png'/> " + catParentInfo.catName + " <img src='/images/bul4.png'/> " + catInfo.catName;
                    bindHome(catID);
                }
            }
        }
        catch (Exception ex) { }
    }
    protected void bindHome(int catID)
    {
        Home_Info[] lstHome = Home_Info.searchHome(catID.ToString(), 1, "");

        repDanhMucNha.DataSource = lstHome.Take(16);
        repDanhMucNha.DataBind();

        int totalPage = (int)Math.Ceiling(ConvertUtility.ToDouble(lstHome.Length) / 16);
        pagerbot.Text = ConvertUtility.buildSimplePaging(totalPage, 1);
    }
}